#include<iostream>
using namespace std;
bool isRun(int year);
int getDaysInMonth(int year, int month);
int main()
{
	int year, month;
	cin >> year >> month;
	cout << getDaysInMonth(year, month) << endl;
	return 0;
}
bool isRun(int year)
{
	if (year % 4 == 0 && year % 100 != 0)
	{
		return true;
	}
	else if (year % 400 == 0)
	{
		return true;
	}
	return false;
}
int getDaysInMonth(int year, int month)
{
	switch (month)
	{
	case 1:
		return 31;
		break;
	case 2:
		if (isRun(year))
		{
			return 29;
		}
		else return 28;
		break;
	case 3:
		return 31;
		break;
	case 4:
		return 30;
		break;
	case 5:
		return 31;
		break;
	case 6:
		return 30;
		break;
	case 7:
		return 31;
		break;
	case 8:
		return 31;
		break;
	case 9:
		return 30;
		break;
	case 10:
		return 31;
		break;
	case 11:
		return 30;
		break;
	case 12:
		return 31;
		break;
	}
}

